package com.centanet.framework.network;

import android.content.Context;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;

/**
 * Volley 请求队列
 */
public final class VolleyRequestQueue {

    private static RequestQueue requestQueue;

    private VolleyRequestQueue() {
        // Utility class.
    }

    /**
     * Application中初始化
     *
     * @param context Context
     */
    public static void init(Context context) {
        if (requestQueue == null)
            requestQueue = Volley.newRequestQueue(context, new OkHttpStack());
    }

    /**
     * 获取RequestQueue
     *
     * @return RequestQueue
     */
    public static RequestQueue getRequestQueue() {
        if (requestQueue == null)
            throw new IllegalArgumentException("RequestQueue not initialized");
        return requestQueue;
    }

}
